package com.hourses.controller;

import com.hourses.page.Page;
import com.hourses.pojo.Result;
import com.hourses.pojo.Store;
import com.hourses.service.impl.StoreServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:
 * @Author:LiTao
 * @Date:2025/5/11 14:28
 */
@RestController
@RequestMapping("/store")
public class StoreController {
    //分页展示仓库列表   http://localhost:3000/api/store/store-page-list
            //store对象
                // storeName
                // storeAddress
                // concat
                // phone
           //page对象
                // pageSize
                // pageNum
                // totalNum
    @Autowired
    private StoreServiceImpl storeService;
    @GetMapping("/store-page-list")
    public Result selectsStoreListByPage(Store store, Page page){
        Result result = storeService.selectsStoreListByPage(store, page);
        return result;
    }

    //修改仓库信息   http://localhost:3000/api/store/store-update
    @RequestMapping("/store-update")
    public Result updateStore(@RequestBody Store store){
        Result result = storeService.updateStore(store);
        return result;
    }

    //添加仓库时判断仓库编号是否存在  http://localhost:3000/api/store/store-num-check?storeNum=001
    @GetMapping("/store-num-check")
    public Result checkStoreNumExists(@RequestParam("storeNum")String storeNum){
        Result result = storeService.checkStoreNumExists(storeNum);
        return result;
    }

    //添加仓库   http://localhost:3000/api/store/store-add
    @PostMapping("/store-add")
    public Result addStore(@RequestBody Store store){
        Result result = storeService.addStore(store);
        return result;
    }

    //删除仓库   http://localhost:3000/api/store/store-delete/6
    @RequestMapping("/store-delete/{storeId}")
    public Result deleteStore(@PathVariable Integer storeId){
        Result result = storeService.deleteStoreByStoreId(storeId);
        return result;
    }
}
